<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
		<head>
			<!-- template designed by Marco Von Ballmoos -->
			<title>File Source for ordering.php</title>
			<link rel="stylesheet" href="../media/stylesheet.css" />
			<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
		</head>
		<body>
						<h1>Source for file ordering.php</h1>
<p>Documentation is available at <a href="../LIST_DMZ_Extensions/_extensions---ordering.php.html">ordering.php</a></p>
<div class="src-code">
<div class="src-code"><ol><li><div class="src-line"><a name="a1"></a><span class="src-php">&lt;?php</span></div></li>
<li><div class="src-line"><a name="a2"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a3"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a4"></a><span class="src-doc">&nbsp;*&nbsp;This&nbsp;class&nbsp;adds&nbsp;additional&nbsp;ordering&nbsp;methods&nbsp;for&nbsp;datamapper.</span></div></li>
<li><div class="src-line"><a name="a5"></a><span class="src-doc">&nbsp;*&nbsp;</span></div></li>
<li><div class="src-line"><a name="a6"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@author</span><span class="src-doc">&nbsp;Andrej&nbsp;Jursa</span></div></li>
<li><div class="src-line"><a name="a7"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@package</span><span class="src-doc">&nbsp;LIST_DMZ_Extensions</span></div></li>
<li><div class="src-line"><a name="a8"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a9"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a10"></a><span class="src-key">class&nbsp;</span><a href="../LIST_DMZ_Extensions/DMZ_Ordering.html">DMZ_Ordering</a>&nbsp;<span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a11"></a>&nbsp;&nbsp;&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a12"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a13"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Handle&nbsp;column&nbsp;as&nbsp;fullname&nbsp;(first&nbsp;name&nbsp;&lt;space&gt;&nbsp;last&nbsp;name)&nbsp;and&nbsp;create&nbsp;order&nbsp;by&nbsp;clause&nbsp;for&nbsp;this&nbsp;column&nbsp;by&nbsp;last&nbsp;name.</span></div></li>
<li><div class="src-line"><a name="a14"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc-type">DataMapper&nbsp;</span><span class="src-doc-var">$object&nbsp;</span><span class="src-doc">model&nbsp;object&nbsp;which&nbsp;will&nbsp;be&nbsp;using&nbsp;this&nbsp;function.</span></div></li>
<li><div class="src-line"><a name="a15"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc-var">$column&nbsp;</span><span class="src-doc">column&nbsp;name&nbsp;in&nbsp;table.</span></div></li>
<li><div class="src-line"><a name="a16"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc-var">$direction&nbsp;</span><span class="src-doc">sorting&nbsp;direction&nbsp;(asc&nbsp;|&nbsp;desc).</span></div></li>
<li><div class="src-line"><a name="a17"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc-type">DataMapper&nbsp;</span><span class="src-doc">returns&nbsp;object&nbsp;for&nbsp;method&nbsp;chaining.</span></div></li>
<li><div class="src-line"><a name="a18"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a19"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../LIST_DMZ_Extensions/DMZ_Ordering.html#methodorder_by_as_fullname">order_by_as_fullname</a><span class="src-sym">(</span><span class="src-var">$object</span><span class="src-sym">,&nbsp;</span><span class="src-var">$column</span><span class="src-sym">,&nbsp;</span><span class="src-var">$direction&nbsp;</span>=&nbsp;<span class="src-str">'asc'</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a20"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$object</span><span class="src-sym">-&gt;</span><span class="src-id">db</span><span class="src-sym">-&gt;</span><span class="src-id">ar_orderby</span><span class="src-sym">[</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-str">'SUBSTRING_INDEX(`'&nbsp;</span>.&nbsp;<span class="src-var">$column&nbsp;</span>.&nbsp;<span class="src-str">'`,&nbsp;\'&nbsp;\',&nbsp;-1)&nbsp;'&nbsp;</span>.&nbsp;<span class="src-sym">(</span><a href="http://www.php.net/strtolower">strtolower</a><span class="src-sym">(</span><span class="src-var">$direction</span><span class="src-sym">)&nbsp;</span>==&nbsp;<span class="src-str">'asc'&nbsp;</span>?&nbsp;<span class="src-str">'ASC'&nbsp;</span>:&nbsp;<span class="src-str">'DESC'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a21"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a22"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$object</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a23"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a24"></a>&nbsp;&nbsp;&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a25"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a26"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Add&nbsp;sorting&nbsp;of&nbsp;table&nbsp;deepest&nbsp;level&nbsp;in&nbsp;related&nbsp;table&nbsp;field.</span></div></li>
<li><div class="src-line"><a name="a27"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc-type">DataMapper&nbsp;</span><span class="src-doc-var">$object&nbsp;</span><span class="src-doc">model&nbsp;object&nbsp;which&nbsp;will&nbsp;be&nbsp;using&nbsp;this&nbsp;function.</span></div></li>
<li><div class="src-line"><a name="a28"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc-var">$related&nbsp;</span><span class="src-doc">slash&nbsp;separated&nbsp;list&nbsp;of&nbsp;deeply&nbsp;related&nbsp;models.</span></div></li>
<li><div class="src-line"><a name="a29"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc-var">$column&nbsp;</span><span class="src-doc">column&nbsp;name&nbsp;in&nbsp;table.</span></div></li>
<li><div class="src-line"><a name="a30"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</span><span class="src-doc-coretag">@param&nbsp;</span><span class="src-doc-type">string&nbsp;</span><span class="src-doc-var">$direction&nbsp;</span><span class="src-doc">sorting&nbsp;direction&nbsp;(asc&nbsp;|&nbsp;desc).</span></div></li>
<li><div class="src-line"><a name="a31"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;</span><span class="src-doc-coretag">@return&nbsp;</span><span class="src-doc-type">DataMapper&nbsp;</span><span class="src-doc">returns&nbsp;object&nbsp;for&nbsp;method&nbsp;chaining.</span></div></li>
<li><div class="src-line"><a name="a32"></a><span class="src-doc">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a33"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">public&nbsp;</span><span class="src-key">function&nbsp;</span><a href="../LIST_DMZ_Extensions/DMZ_Ordering.html#methodorder_by_related_as_fullname">order_by_related_as_fullname</a><span class="src-sym">(</span><span class="src-var">$object</span><span class="src-sym">,&nbsp;</span><span class="src-var">$related</span><span class="src-sym">,&nbsp;</span><span class="src-var">$column</span><span class="src-sym">,&nbsp;</span><span class="src-var">$direction&nbsp;</span>=&nbsp;<span class="src-str">'asc'</span><span class="src-sym">)&nbsp;</span><span class="src-sym">{</span></div></li>
<li><div class="src-line"><a name="a34"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$related_table&nbsp;</span>=&nbsp;<span class="src-var">$object</span><span class="src-sym">-&gt;</span><span class="src-id">_add_related_table</span><span class="src-sym">(</span><span class="src-var">$related</span><span class="src-sym">,&nbsp;</span><span class="src-var">$object</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a35"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a36"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-var">$object</span><span class="src-sym">-&gt;</span><span class="src-id">db</span><span class="src-sym">-&gt;</span><span class="src-id">ar_orderby</span><span class="src-sym">[</span><span class="src-sym">]&nbsp;</span>=&nbsp;<span class="src-str">'SUBSTRING_INDEX('&nbsp;</span>.&nbsp;&nbsp;<span class="src-var">$object</span><span class="src-sym">-&gt;</span><span class="src-id">db</span><span class="src-sym">-&gt;</span><span class="src-id">protect_identifiers</span><span class="src-sym">(</span><span class="src-var">$related_table</span><span class="src-sym">)</span>.&nbsp;<span class="src-str">'.`'&nbsp;</span>.&nbsp;<span class="src-var">$column&nbsp;</span>.&nbsp;<span class="src-str">'`,&nbsp;\'&nbsp;\',&nbsp;-1)&nbsp;'&nbsp;</span>.&nbsp;<span class="src-sym">(</span><a href="http://www.php.net/strtolower">strtolower</a><span class="src-sym">(</span><span class="src-var">$direction</span><span class="src-sym">)&nbsp;</span>==&nbsp;<span class="src-str">'asc'&nbsp;</span>?&nbsp;<span class="src-str">'ASC'&nbsp;</span>:&nbsp;<span class="src-str">'DESC'</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a37"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a38"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-key">return&nbsp;</span><span class="src-var">$object</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a39"></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="src-sym">}</span></div></li>
<li><div class="src-line"><a name="a40"></a>&nbsp;&nbsp;&nbsp;&nbsp;</div></li>
<li><div class="src-line"><a name="a41"></a><span class="src-sym">}</span></div></li>
</ol></div>
</div>
	<p class="notes" id="credit">
		Documentation generated on Fri, 13 Sep 2013 12:32:40 +0200 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.4</a>
	</p>
	</body>
</html>